import {
  update
} from "./render";

//实现数据响应式和访问属性代理
export default function (vm, data, propsPool) {

  //挂载data到vm实例
  vm.$data = data;

  for (let key in vm.$data) {
    // console.log(key); 
    //isShowImg1 / isShowImg2

    Object.defineProperty(vm, key, {
      get() {
        //this.a -> vm.$data[key]
        return vm.$data[key];
      },
      set(newValue) {
        vm.$data[key] = newValue;

        //更新
        update(vm, key, propsPool);
      }
    });
  }
}